package com.ruoyi.web.controller.memberCoupon;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TablePassCards;
import com.ruoyi.system.service.ITablePassCardsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 桌台次卡产品配置 Controller
 *
 * @author ruoyi
 * @date 2025-05-23
 */
@Api(tags="桌台次卡次品配置")
@RestController
@RequestMapping("/system/tablePassCards")
public class TablePassCardsController extends BaseController
{
    @Autowired
    private ITablePassCardsService tablePassCardsService;

    /**
     * 查询桌台次卡产品配置列表
     */
    @ApiOperation("查询桌台次卡次品配置列表")
    @PreAuthorize("@ss.hasPermi('system:cards:list')")
    @GetMapping("/list")
    public TableDataInfo list(TablePassCards tablePassCards)
    {
        startPage();
        List<TablePassCards> list = tablePassCardsService.selectTablePassCardsList(tablePassCards);
        return getDataTable(list);
    }

    /**
     * 导出桌台次卡产品配置列表
     */
    @ApiOperation("导出桌台次卡次品配置列表")
    @PreAuthorize("@ss.hasPermi('system:cards:export')")
    @Log(title = "桌台次卡产品配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TablePassCards tablePassCards)
    {
        List<TablePassCards> list = tablePassCardsService.selectTablePassCardsList(tablePassCards);
        ExcelUtil<TablePassCards> util = new ExcelUtil<TablePassCards>(TablePassCards.class);
        util.exportExcel(response, list, "桌台次卡产品配置数据");
    }

    /**
     * 通过id获取桌台次卡产品配置详细信息
     */
    @ApiOperation("通过id获取桌台次卡产品配置详细信息")
    @PreAuthorize("@ss.hasPermi('system:cards:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tablePassCardsService.selectTablePassCardsById(id));
    }

    /**
     * 新增桌台次卡产品配置
     */
    @ApiOperation("新增桌台次卡产品配置")
    @PreAuthorize("@ss.hasPermi('system:cards:add')")
    @Log(title = "桌台次卡产品配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TablePassCards tablePassCards)
    {
        return toAjax(tablePassCardsService.insertTablePassCards(tablePassCards));
    }

    /**
     * 修改桌台次卡产品配置
     */
    @ApiOperation("修改桌台次卡产品配置")
    @PreAuthorize("@ss.hasPermi('system:cards:edit')")
    @Log(title = "桌台次卡产品配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TablePassCards tablePassCards)
    {
        return toAjax(tablePassCardsService.updateTablePassCards(tablePassCards));
    }

    /**
     * 通过id批量删除桌台次卡产品配置信息
     */
    @ApiOperation("通过id批量桌台次卡产品配置信息")
    @PreAuthorize("@ss.hasPermi('system:cards:remove')")
    @Log(title = "桌台次卡产品配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tablePassCardsService.deleteTablePassCardsByIds(ids));
    }
}
